package com.ruoyi.web.controller.app.controller;

import com.ruoyi.framework.web.exception.base.XResult;
import com.ruoyi.web.controller.app.service.AppCodePayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AppCodePayController
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2019/1/2 0002 16:32
 **/
@RestController
@RequestMapping("/app/codepay")
@Api(tags = "收付款")
public class AppCodePayController {
    @Autowired
    private AppCodePayService appCodePayService;

    @PostMapping("pay")
    @ApiOperation(value = "付款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "收款人ID号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "money", value = "金额", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "付款人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "备注", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "payPassword", value = "支付密码", required = true, dataType = "String", paramType = "query")
    })
    public XResult codePay(String memberId,String userId,String payPassword,String money,String title){
        return new XResult("操作成功",appCodePayService.payMoney(memberId,userId,payPassword,money,title));
    }

    @PostMapping("acceptCode")
    @ApiOperation(value = "生成收款码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "付款人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "money", value = "金额", required = true, dataType = "String", paramType = "query")
    })
    public XResult acceptCode(String userId,String money){
        return new XResult("操作成功",appCodePayService.acceptCode(userId,money));
    }

    @PostMapping("accept")
    @ApiOperation(value = "收款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderSn", value = "订单号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "付款人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "money", value = "金额", required = true, dataType = "String", paramType = "query")
    })
    public XResult accept(String orderSn,String userId,String money){
        return new XResult("操作成功",appCodePayService.acceptMoney(orderSn,userId,money));
    }

    @PostMapping("transfer")
    @ApiOperation(value = "转账订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "转账人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "收款人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "备注", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "money", value = "金额", required = true, dataType = "String", paramType = "query")
    })
    public XResult transfer(String memberId,String userId,String money,String payPassword,String title){
        return new XResult("操作成功",appCodePayService.transferById(memberId,userId,money,payPassword,title));
    }
    @PostMapping("transferMoney")
    @ApiOperation(value = "收帐")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderSn", value = "订单号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "收款人ID", required = true, dataType = "String", paramType = "query")
    })
    public XResult transferMoney(String orderSn,String userId){
        return new XResult("操作成功",appCodePayService.transferMoney(orderSn,userId));
    }


}
